-- MySQL Workbench Forward Engineering

SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';

-- -----------------------------------------------------
-- Schema kazaku5d_hour
-- -----------------------------------------------------

-- -----------------------------------------------------
-- Schema kazaku5d_hour
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `kazaku5d_hour` DEFAULT CHARACTER SET utf8 ;
USE `kazaku5d_hour` ;

-- -----------------------------------------------------
-- Table `kazaku5d_hour`.`students`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `kazaku5d_hour`.`students` (
  `id` INT NOT NULL AUTO_INCREMENT,
  `last_name` VARCHAR(45) NOT NULL,
  `first_name` VARCHAR(45) NOT NULL,
  `patronymic` VARCHAR(45) NULL,
  PRIMARY KEY (`id`))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `kazaku5d_hour`.`reasons`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `kazaku5d_hour`.`reasons` (
  `id` INT NOT NULL AUTO_INCREMENT,
  `reason` VARCHAR(45) NOT NULL,
  PRIMARY KEY (`id`))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `kazaku5d_hour`.`skip`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `kazaku5d_hour`.`skip` (
  `id` INT NOT NULL AUTO_INCREMENT,
  `id_student` INT NOT NULL,
  `date` DATE NOT NULL,
  `id_reason` INT NOT NULL,
  PRIMARY KEY (`id`),
  INDEX `fk_skip_students_idx` (`id_student` ASC) VISIBLE,
  INDEX `fk_skip_reasons_idx` (`id_reason` ASC) VISIBLE,
  CONSTRAINT `fk_skip_students`
    FOREIGN KEY (`id_student`)
    REFERENCES `kazaku5d_hour`.`students` (`id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_skip_reasons`
    FOREIGN KEY (`id_reason`)
    REFERENCES `kazaku5d_hour`.`reasons` (`id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
